class DmsUserqualifications {
  String? id;
  String? state;
  String? departmentId;
  String? departmentName;
  String? certificatetypeId;
  String? certificatetypeName;
  String? certificateno;
  String? certificatename;
  String? holderId;
  String? holderName;
  String? traindate;
  String? Issuingcompany;
  String? Issuingdate;
  String? expirydate;
  String? remark;
  String? createUid;
  String? createDate;

  DmsUserqualifications({
    this.id,
    this.state,
    this.departmentId, //部门
    this.departmentName,
    this.certificatetypeId, //证书类别
    this.certificatetypeName,
    this.certificateno,
    this.certificatename,
    this.holderId, //持有人
    this.holderName,
    this.traindate,
    this.Issuingcompany,
    this.Issuingdate,
    this.expirydate,
    this.remark,
    this.createUid,
    this.createDate,
  });

  DmsUserqualifications copyWith({
    String? id,
    String? certificateno,
    String? departmentId,
    String? holderId,
    String? processId,
    String? certificatetypeName,
    String? departmentName,
    String? traindate,
    String? Issuingcompany,
    String? Issuingdate,
    String? expirydate,
    String? remark,
    String? createUid,
    String? createDate,
  }) {
    return new DmsUserqualifications(
      id: id ?? this.id,
      certificateno: certificateno ?? this.certificateno,
      departmentId: departmentId ?? this.departmentId,
      holderId: holderId ?? this.holderId,
      certificatetypeName: certificatetypeName ?? this.certificatetypeName,
      departmentName: departmentName ?? this.departmentName,
      traindate: traindate ?? this.traindate,
      Issuingcompany: Issuingcompany ?? this.Issuingcompany,
      Issuingdate: Issuingdate ?? this.Issuingdate,
      expirydate: expirydate ?? this.expirydate,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
    );
  }

  @override
  String toString() {
    return '''DmsUserqualifications{
      id: id,
      certificateno: certificateno,
      departmentId: departmentId,
      holderId: holderId,
      processId: processId,
      certificatetypeName: certificatetypeName,
      departmentName: departmentName,
      traindate: traindate,
      Issuingcompany: Issuingcompany,
      Issuingdate: Issuingdate,
      expirydate: expirydate,
      remark: remark,
      createUid: createUid,
      createDate: createDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is DmsUserqualifications &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          certificateno == other.certificateno &&
          departmentId == other.departmentId &&
          holderId == other.holderId &&
          certificatetypeName == other.certificatetypeName &&
          departmentName == other.departmentName &&
          traindate == other.traindate &&
          Issuingcompany == other.Issuingcompany &&
          Issuingdate == other.Issuingdate &&
          expirydate == other.expirydate &&
          remark == other.remark &&
          createUid == other.createUid &&
          createDate == other.createDate);

  factory DmsUserqualifications.fromMap(Map<String, dynamic> map) {
    return new DmsUserqualifications(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      certificateno: map['certificateno'] != false
          ? map['certificateno'].toString() as String?
          : "",
      certificatename: map['certificatename'] != false
          ? map['certificatename'].toString() as String?
          : "",
      departmentId: map['department_id'] != false
          ? map['department_id'][0].toString() as String?
          : "",
      departmentName: map['department_id'] != false
          ? map['department_id'][1].toString() as String?
          : "",
      holderId: map['holder_id'] != false
          ? map['holder_id'][0].toString() as String?
          : "",
      holderName: map['holder_id'] != false
          ? map['holder_id'][1].toString() as String?
          : "",
      certificatetypeName: map['certificatetype_id'] != false
          ? map['certificatetype_id'][1].toString() as String?
          : "",
      certificatetypeId: map['certificatetype_id'] != false
          ? map['certificatetype_id'][0].toString() as String?
          : "",
      traindate: map['traindate'] != false
          ? map['traindate'].toString() as String?
          : "",
      Issuingcompany: map['Issuingcompany'] != false
          ? map['Issuingcompany'].toString() as String?
          : "",
      Issuingdate: map['Issuingdate'] != false
          ? map['Issuingdate'].toString() as String?
          : "",
      expirydate: map['expirydate'] != false
          ? map['expirydate'].toString() as String?
          : "",
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      createUid: map['write_uid'] != false
          ? map['write_uid'][1].toString() as String?
          : "",
      createDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'certificateno': this.certificateno,
      'departmentId': this.departmentId,
      'holderId': this.holderId,
      'certificatetypeName': this.certificatetypeName,
      'departmentName': this.departmentName,
      'traindate': this.traindate,
      'Issuingcompany': this.Issuingcompany,
      'Issuingdate': this.Issuingdate,
      'expirydate': this.expirydate,
      'remark': this.remark,
      'createUid': this.createUid,
      'createDate': this.createDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.departmentId != null && this.departmentId != '')
        ['department_id', '=', int.parse(this.departmentId!)],
      if (this.certificatetypeId != null && this.certificatetypeId != '')
        ['certificatetype_id', '=', int.parse(this.certificatetypeId!)],
      if (this.certificateno != null && this.certificateno != '')
        ['certificateno', 'like', '%${this.certificateno}%'],
      if (this.certificatename != null && this.certificatename != '')
        ['certificatename', 'like', '%${this.certificatename}%'],
      if (this.holderName != null && this.holderName != '')
        ['holder', 'like', '%${this.holderName}%'],
    ] as List;
    // if (list.length == 0) {
    //   list.add(['id', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  List toDomainStateList() {
    List list = [
      if (this.state != null && this.state != '')
        ['state', '=', int.parse(this.state!)]
      else
        ['state', '=', 1],
      if (this.departmentId != null && this.departmentId != '')
        ['department_id', '=', int.parse(this.departmentId!)],
      if (this.certificatetypeId != null && this.certificatetypeId != '')
        ['certificatetype_id', '=', int.parse(this.certificatetypeId!)],
      if (this.certificateno != null && this.certificateno != '')
        ['certificateno', 'like', '%${this.certificateno}%'],
      if (this.certificatename != null && this.certificatename != '')
        ['certificatename', 'like', '%${this.certificatename}%'],
      if (this.holderName != null && this.holderName != '')
        ['holder', 'like', '%${this.holderName}%'],
    ] as List;
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'certificateno': this.certificateno,
      'certificatename': this.certificatename,
      'certificatetype_id': int.parse(this.certificatetypeId!),
      'department_id': int.parse(this.departmentId!),
      'holder_id': int.parse(this.holderId!),
      'traindate': this.traindate,
      'Issuingcompany': this.Issuingcompany,
      'Issuingdate': this.Issuingdate,
      'expirydate': this.expirydate,
      'remark': this.remark,
    } as Map<String, dynamic>;
  }
}
